package com.itydl.sweepview1;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.AbsListView;
import android.widget.ListView;

import com.itydl.sweepview1.adapter.MyAdapter;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity{

    private String TAG = "MainActivity";
    private ListView mListView;
    private MyAdapter mMyAdapter;
    List<String> mDatas = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mListView = (ListView) findViewById(R.id.lv);
        for (int i = 0; i < Strings.NAMES.length; i++) {
        	mDatas.add(Strings.NAMES[i]);
        }
        mMyAdapter = new MyAdapter(mDatas);
        mListView.setAdapter(mMyAdapter);
        mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                if(scrollState == SCROLL_STATE_TOUCH_SCROLL){
                    //触动关闭所有SweepView方法
                    mMyAdapter.cloasAllSweepView();
                }
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {

            }
        });
    }

}
